import { OmitType } from "@nestjs/swagger";
import { IsArray, IsNumber, IsOptional, IsString } from "class-validator";
import { PaginationDto } from "src/common/dto/pagination.dto";
import { User } from "../entities/user.entity";
import { Type } from "class-transformer";

export class ReqUserListDto extends PaginationDto {
  @IsString()
  @IsOptional()
  username?: string;

  @IsString()
  dept_id: string;
}

export class ReqAddUserDto extends OmitType(User, ["userId"] as const) {
  // 部门id
  @Type()
  @IsNumber()
  dept_id: number;

  // 角色id数组
  @IsArray()
  roleIds: number[];
}

export class ReqUpdateUserDto extends OmitType(User, ["password"] as const) {
  @Type()
  dept_id: string | number;

  @IsArray()
  roleIds: number[];
}
